
class ReportSystemController {
    
    def index = { redirect(action:list,params:params) }

    // the delete, save and update actions only accept POST requests
    def allowedMethods = [delete:'POST', save:'POST', update:'POST']

    def list = {
        if(!params.max) params.max = 20
        [ reportSystemList: ReportSystem.list( params ) ]
    }

    def show = {
        def reportSystem = ReportSystem.get( params.id )

        if(!reportSystem) {
            flash.message = "ReportSystem not found with id ${params.id}"
            redirect(action:list)
        }
        else { return [ reportSystem : reportSystem ] }
    }

    def delete = {
        def reportSystem = ReportSystem.get( params.id )
        if(reportSystem) {
            reportSystem.delete()
            flash.message = "ReportSystem ${params.id} deleted"
            redirect(action:list)
        }
        else {
            flash.message = "ReportSystem not found with id ${params.id}"
            redirect(action:list)
        }
    }

    def edit = {
        def reportSystem = ReportSystem.get( params.id )

        if(!reportSystem) {
            flash.message = "ReportSystem not found with id ${params.id}"
            redirect(action:list)
        }
        else {
            return [ reportSystem : reportSystem ]
        }
    }

    def update = {
        def reportSystem = ReportSystem.get( params.id )
        if(reportSystem) {
            reportSystem.properties = params
            if(!reportSystem.hasErrors() && reportSystem.save()) {
                flash.message = "ReportSystem ${params.id} updated"
                redirect(action:show,id:reportSystem.id)
            }
            else {
                render(view:'edit',model:[reportSystem:reportSystem])
            }
        }
        else {
            flash.message = "ReportSystem not found with id ${params.id}"
            redirect(action:edit,id:params.id)
        }
    }

    def create = {
        def reportSystem = new ReportSystem()
        reportSystem.properties = params
        return ['reportSystem':reportSystem]
    }

    def save = {
        def reportSystem = new ReportSystem(params)
		reportSystem.setDateCreated(new Date())
        if(!reportSystem.hasErrors() && reportSystem.save()) {
            flash.message = "ReportSystem ${reportSystem.id} created"
            redirect(action:show,id:reportSystem.id)
        }
        else {
            render(view:'create',model:[reportSystem:reportSystem])
        }
    }
}